import { fileURLToPath } from 'node:url'
import { xlsxToArray, getXlsxData, saveJson } from '../../utils.js'

const getFilePath = path => fileURLToPath(new URL(path, import.meta.url))
const src = getFilePath('src/西华县各乡镇数据(含code+经纬度).xlsx')
const dist = getFilePath('dist/村数据.json')

const xlsxData = getXlsxData(src)
const xlsxArr = xlsxToArray(xlsxData[0].data)

const saveData = xlsxArr.map(item => {
  return {
    townName: item['乡镇级'],
    villageName: item['村级'],
    lnglat: [item['经度'], item['维度']],
  }
})

saveJson(dist, saveData)
